package com.py.pythink.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.py.pythink.bo.UserDetailAddBo;
import com.py.pythink.bo.UserDetailBo;
import com.py.pythink.entity.UserDetail;
import com.py.pythink.vo.R;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface UserDetailDao extends BaseMapper<UserDetail> {
    //补充注册完以后剩余的个人信息
    @Update("update t_userdetail set oid=#{oid},nickname=#{nickname},sex=#{sex},birthday=#{birthday},address=#{address} where uid=#{uid}")
    int  update(UserDetailAddBo userDetailAddBo);

    //根据uid来更换头像
    @Update("update t_userdetail set oid=#{oid} where uid=#{uid}")
    int  updateByUid(@Param("oid") int oid,@Param("uid") int uid );

    //根据三表来查询用户的详细信息
    //1.获得用户详情表的所有信息 2.获得用户表中用户的手机号 3.获得oos中的头像
    @Select("select ud.*,uu.phone,oo.preurl from t_userdetail ud inner join t_user uu ON\n" +
            "ud.uid=uu.id inner join t_osslog oo on ud.oid=oo.id where ud.uid=#{uid}")
    @ResultType(UserDetailBo.class)
    UserDetailBo selectByUids(int uid);

    @Select("select * from t_userdetail where uid=#{uid}")
    UserDetail selectByUid(int uid);
}
